﻿#region Using

using System;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Serialization;
using WSMon.Core.Configuration;
using WSMon.Engine;

#endregion

namespace ConsoleApplication1
{
    public class xmlTest
    {
        public xmlTest()
        {
            #region Tests

            #region EmailAccounts

            string tmpVerifKey = Guid.NewGuid().ToString();
            var smtpEmailAccount = new EmailAccountConfiguration
                                       {
                                           Host = "smtp.gmail.com",
                                           Port = 587,
                                           EnableSsl = true,
                                           Mail = "omerfarukzorlu.blog@gmail.com",
                                           ToMail = "omerfarukzorlu.blog@gmail.com",
                                           UserName = "omerfarukzorlu.blog@gmail.com",
                                           Password = "omer123omer",
                                       };

            var pop3EmailAccount = new EmailAccountConfiguration
                                       {
                                           Host = "pop.gmail.com",
                                           Port = 995,
                                           EnableSsl = true,
                                           Mail = "omerfarukzorlu.blog@gmail.com",
                                           UserName = "omerfarukzorlu.blog@gmail.com",
                                           Password = "omer123omer",
                                       };

            #endregion

            #region HttpRequestConf

            var httpRequestConfiguration = new HttpRequestConfiguration();
            httpRequestConfiguration.Url = "http://yahoo.com";
            //httpRequestConfiguration.NetworkCredential = null;

            #endregion

            #region SourceCode

            var sourceCodeConfiguration = new SourceCodeConfiguration();
            sourceCodeConfiguration.HttpRequestConfig.Url = "http://www.yahoo.com";
            sourceCodeConfiguration.WhiteWords.Add("html");
            sourceCodeConfiguration.BlackWords.Add("hacked");

            #endregion

            #region FtpConfig

            var ftpConfiguration = new FtpConfiguration();
            ftpConfiguration.Host = "ftp://omerfarukzorlu.com";
            ftpConfiguration.Port = 21;
            ftpConfiguration.EnableSsl = false;
            ftpConfiguration.RemoteFolder = "httpdocs/test";
            ftpConfiguration.NetworkCredential = new NetworkCredential("cenqqnet", "cen64507");

            #endregion

            #region DnsConfig

            var dnsConfiguration = new DnsConfiguration();
            dnsConfiguration.Host = "www.google.com";
            dnsConfiguration.IpAddresses = new string[2] {"208.69.35.230", "208.69.35.231"};

            #endregion

            #endregion

            var configuration = new Configuration();
            configuration.Hostings.Add(new Hosting
                                           {
                                               Delay = 3,
                                               SmtpAccountConfig = smtpEmailAccount,
                                               HttpRequestConfig = httpRequestConfiguration,
                                               SourceCodeConfig = sourceCodeConfiguration,
                                               FtpConfig = ftpConfiguration,
                                               SslCheckUrl = "www.pegem.net",
                                               DnsConfig = dnsConfiguration,
                                               Pop3AccountConfig = pop3EmailAccount
                                           });

            try
            {
                var strWriter = new StringWriter(CultureInfo.InvariantCulture);
                var xSer = new XmlSerializer(typeof (Configuration));
                xSer.Serialize(strWriter, configuration);

                var sw = new StreamWriter("c:\\cnf2.xml", false, Encoding.UTF8);
                sw.Write(strWriter);
                sw.Close();
            }
            catch (Exception Ex)
            {
                throw;
            }
        }
    }
}